<template>
  <div id="name">
    <div class="wl-body jd-body">
      <div class="flexsa">
        <div class="cjbtns" @click="goto()">
          {{ s.gainpackLevel ? $t("m.ckfhjl") : $t("m.ljjx") }}
        </div>
      </div>
      <div class="cjjd slideIn">
        <div class="sback" @click="guanbi"></div>

        <img :src="item" alt="" height="100% " width="100%"  v-for="(item, index) in imgurl" :key="index"/>
        <div class="wl-bottom"></div>
      </div>
    </div>
    <van-popup v-model="buyshow" class="yqbd-bg">
      <div class="yama">
        <div class="txte">{{ $t("m.jxcjjd") }}</div>

        <div>
          <div class="tts">{{ $t("m.fhizzf") }} {{ list.spec }} USDT</div>
        </div>
        <div class="btns" @click="yqmaos()">{{ $t("m.queding") }}</div>
      </div>
    </van-popup>
  </div>
</template>

<script>
export default {
  name: "name",
  data() {
    return {
      isPublish: false,
      buyshow: false,
      suoding: false,
      imgurl: "",
      list: [],
      s: "",
      imgy: [
        require("../assets/timg/d1.png"),
        require("../assets/timg/d2.png"),
        require("../assets/timg/d3.png"),
        require("../assets/timg/d4.png"),
        require("../assets/timg/d5.png"),
        require("../assets/timg/d6.png"),
      ],
      imgz: [
        require("../assets/timg/c1.png"),
        require("../assets/timg/c2.png"),
        require("../assets/timg/c3.png"),
        require("../assets/timg/c4.png"),
        require("../assets/timg/c5.png"),
        require("../assets/timg/c6.png"),
      ],
    };
  },
  created() {
    if (this.$store.getters.language == "zh-CN") {
      this.imgurl = this.imgz;
    } else {
      this.imgurl = this.imgy;
    }
    this.s = JSON.parse(sessionStorage.getItem("s"));
    this.getdata();
    this.getlist();
  },
  methods: {
    guanbi() {
      this.$router.go(-1);
    },
    goto() {
      if (this.s.gainpackLevel) {
        sessionStorage.setItem("i", 2);
        this.$router.push({ path: "sy" });
      } else {
        this.buyshow = true;
      }
    },
    yqmaos() {
      this.buyshow = false;
      if (this.suoding) {
        return;
      } else {
        this.suoding = true;

        this.sc = false;
        let datas = {
          uid: this.$store.getters.nameid,
          gid: 1,
          spec: this.list.dot,
        };
        this.$post({
          url: "ums-gainpacket-history/createObj",
          data: datas,
          callback: (data) => {
            this.$nextTick(function () {
              var s = data.data;
              if (s) {
                this.$toast(this.$i18n.t("m.gmcg"));
                this.getdata();
              } else {
                if (this.$store.getters.language == "zh-CN") {
                  this.$toast(data.message);
                } else {
                  if (data.message == "钱包余额不足") {
                    this.$toast(this.$i18n.t("m.qbyebz"));
                  } else {
                    this.$toast(this.$i18n.t("m.messageerror"));
                  }
                }
                this.suoding = false;
              }
            });
          },
        }).catch(() => {
          this.suoding = false;
          this.$toast(this.$i18n.t("m.messageerror"));
        });
      }
    },
    getdata() {
      let datas = {
        params: {
          address: this.$store.getters.userWallet,
        },
      };
      this.$get({
        url: "wms-wallet/getWallet",
        data: datas,
        callback: (data) => {
          this.$nextTick(function () {
            this.s = data.data;
            if (this.s) {
              this.suoding = false;
              this.$store.commit("nameid", this.s.id);
              this.$store.commit("s", this.s);
            }
          });
        },
      }).catch(() => {
        this.$toast(this.$i18n.t("m.errordata"));
      });
    },
    getlist() {
      let datas = {
        params: {
          state: 1,
        },
      };
      this.$get({
        url: "ums-gainpacket/getList",
        data: datas,
        callback: (data) => {
          this.$nextTick(function () {
            var s = data.data;
            if (s) {
              this.list = s[0];
            }
          });
        },
      }).catch(() => {
        this.$toast(this.$i18n.t("m.errordata"));
      });
    },
  },
};
</script>

<style lang="scss" scoped>
</style>